package Functions;

import java.util.LinkedList;

import operations.FunctionOperations;

public class ErrorBound {
private  double calcK(FunctionOperations myFunctions,double a , double b){
	LinkedList<Element> diff = myFunctions.differentiate();
	FunctionOperations differentiation = new FunctionOperations(diff);
	double fdashA = differentiation.evaluate(a); 
	double fdashb = differentiation.evaluate(b); 
	return Math.max(Math.abs(fdashA), Math.abs(fdashb));
	
}
public double calculateErrorBound(int noOfItertions,FunctionOperations myFunctions,double a , double b,double x0 , double x1){
	double k = calcK(myFunctions, a, b);
	double diff = 1-k;
	double kn = Math.pow(k, noOfItertions);
	double difference = x1-x0;
	return ((kn*difference)/diff);
}
}
